home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
Supplement
/
my stuff
/
late bind example
< prev
next >
Wrap
Text File
|
1994-06-24
|
1KB
|
50 lines
\ suppose you have an array with object addresses stored in it:
4 array objectArray
\ make three objects
var myVar
int myInt
rect myRect
string myString
new: myString
myVar myInt myRect myString put: objectArray
\ now put a few values in the objects
12 put: myVar
10 put: myInt
10 10 100 100 put: myRect
" hello" put: myString
\ now draw each object, but late bind to the objects held in the array:
print: [ 0 at: objectArray ]
print: [ 1 at: objectArray ]
print: [ 2 at: objectArray ]
print: [ 3 at: objectArray ]
\ or do it like this
: printStuff limit: objectArray 0 DO print: [ i at: objectArray ] LOOP ;
printStuff
\ suppose myVar points to another object like myRect
myRect put: myVar
print: [ obj: myVar ] \ is the same as
print: [ get: myVar ]
\ note: printstuff will send the print: message to each object in the
\ objectArray. Since myVar now holds an object itself, to print the
\ second object (in this case myRect), one must do this:
\ print: [ obj: [ 0 at: objectArray ] ]